package com.allwees.bs.module.scm.transform;

import com.allwees.bs.core.modelbase.transform.ObjectTransformFactory;
import com.allwees.bs.module.oms.entity.OmsOrderItem;
import com.allwees.bs.module.scm.entity.ScmAllocateOrderSku;
import com.allwees.core.common.constant.EStatus;

public class OmsOrderItemToScmAllocateOrderSkuTransformFactory extends ObjectTransformFactory<OmsOrderItem, ScmAllocateOrderSku>  {

    @Override
    public boolean match(Class<?> f, Class<?> t) {
        return f.getName().equals(OmsOrderItem.class.getName()) && t.getName().equals(ScmAllocateOrderSku.class.getName());
    }

    @Override
    protected ScmAllocateOrderSku create() {
        return new ScmAllocateOrderSku();
    }

    @Override
    protected ScmAllocateOrderSku transform(OmsOrderItem from, ScmAllocateOrderSku target) {
        target = super.transform(from, target);
        target.setOrderItemUuid(from.getUuid());
        target.setOrderTakeEffectAt(target.getCreatedAt());
        return target;
    }

    @Override
    protected ScmAllocateOrderSku perfect(ScmAllocateOrderSku allocateOrderSku) {
        allocateOrderSku.setEStatus(EStatus.NORMAL);
        return allocateOrderSku;
    }
}
